// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=1795
// 난이도: 하

//#define COMPILE_P1795
#ifdef COMPILE_P1795

#include <fstream>

using namespace std;

int n;

ifstream in("input.txt");

bool input() {
	in >> n;
	if (n == 0)
		return false;
	else
		return true;
}

ofstream out("output.txt");

void output() {
	int count = 0;
	for (int i = 1; i <= 9; i++)
		for (int j = i; j <= 9; j++)
			if ((i + j < n) && ((n - i - j) >= j) && ((n - i - j) <= 9)) {
				count++;
				out << i << " " << j << " " << n - i - j << "\n";
			}
	out << count << "\n\n";


}

int main() {
	while (input()) {
		output();
	}
	in.close();
	out.close();
    return 0;
}


#endif
